package com.think.common.enums.serialize;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.think.common.cons.SysCons;
import com.think.common.enums.IEnum;
import org.springframework.http.HttpStatus;

import java.io.IOException;

/**
 * <p>
 * jackson HttpStatus 序列化器
 * </p>
 *
 * @author xwj
 * @date 2019/4/11
 */
public class HttpStatusSerialize extends StdSerializer<HttpStatus> {

    public HttpStatusSerialize(Class<HttpStatus> i) {
        super(i);
    }

    @Override
    public void serialize(HttpStatus httpStatus, JsonGenerator gen, SerializerProvider provider) throws IOException {
        int code = httpStatus.value();
        gen.writeNumber(code);
    }
}
